        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>Sweep class / box2d_html Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d_html" data-type="Sweep">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d_html.html">box2d_html</a> &rsaquo; <a href="../box2d_html/Sweep.html">Sweep</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>Sweep</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<pre class="source">
class Sweep {
  /** Local center of mass position. */
  final Vector localCenter;

  /** Center world positions. */
  final Vector centerZero;
  final Vector center;

  /** World angles. */
  num angleZero;
  num angle;

  /**
   * Constructs a new Sweep with centers initialized to the origin and angles
   * set to zero.
   */
  Sweep()
      : localCenter = new Vector(),
        centerZero = new Vector(),
        center = new Vector(),
        angleZero = 0,
        angle = 0;

  /**
   * Constructs a new sweep that is a copy of the given Sweep.
   */
  Sweep.copy(Sweep other)
      : localCenter = new Vector.copy(other.localCenter),
        centerZero = new Vector.copy(other.centerZero),
        center = new Vector.copy(other.center),
        angleZero = other.angleZero,
        angle = other.angle;

  /**
   * Returns true if given object is equal to this sweep. Two sweeps are equal
   * if their fields are equal.
   */
  bool operator ==(other) {
    return localCenter == other.localCenter &amp;&amp; centerZero == other.centerZero
        &amp;&amp; center == other.center &amp;&amp; angleZero == other.angleZero &amp;&amp;
        angle == other.angle;
  }

  /**
   * Sets this Sweep equal to the given Sweep.
   */
  void setFrom(Sweep other) {
    localCenter.setFrom(other.localCenter);
    centerZero.setFrom(other.centerZero);
    center.setFrom(other.center);
    angleZero = other.angleZero;
    angle = other.angle;
  }

  void normalize() {
    num d = MathBox.TWO_PI * (angleZero / MathBox.TWO_PI).floor();
    angleZero -= d;
    angle -= d;
  }

  /**
   * Computes the interpolated transform at a specific time.
   * Time is the normalized time in [0,1].
   */
  void getTransform(Transform xf, num alpha) {
    assert (xf != null);

    xf.position.x = (1.0 - alpha) * centerZero.x + alpha * center.x;
    xf.position.y = (1.0 - alpha) * centerZero.y + alpha * center.y;
    xf.rotation.setAngle((1.0 - alpha) * angleZero + alpha * angle);

    // Shift to origin
    xf.position.x -= xf.rotation.col1.x * localCenter.x + xf.rotation.col2.x
        * localCenter.y;
    xf.position.y -= xf.rotation.col1.y * localCenter.x + xf.rotation.col2.y
        * localCenter.y;
  }

  /**
   * Advances the sweep forward, resulting in a new initial state.
   * Time is the new initial time.
   */
  void advance(num time) {
    centerZero.x = (1 - time) * centerZero.x + time * center.x;
    centerZero.y = (1 - time) * centerZero.y + time * center.y;
    angleZero = (1 - time) * angleZero + time * angle;
  }
}
</pre>
</div>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="Sweep">
<button class="show-code">Code</button>
new <strong>Sweep</strong>() <a class="anchor-link" href="#Sweep"
              title="Permalink to Sweep.Sweep">#</a></h4>
<div class="doc">
<p>Constructs a new Sweep with centers initialized to the origin and angles
set to zero.</p>
<pre class="source">
Sweep()
    : localCenter = new Vector(),
      centerZero = new Vector(),
      center = new Vector(),
      angleZero = 0,
      angle = 0;
</pre>
</div>
</div>
<div class="method"><h4 id="Sweep.copy">
<button class="show-code">Code</button>
new <strong>Sweep.copy</strong>(<a href="../box2d_html/Sweep.html">Sweep</a> other) <a class="anchor-link" href="#Sweep.copy"
              title="Permalink to Sweep.Sweep.copy">#</a></h4>
<div class="doc">
<p>Constructs a new sweep that is a copy of the given Sweep.</p>
<pre class="source">
Sweep.copy(Sweep other)
    : localCenter = new Vector.copy(other.localCenter),
      centerZero = new Vector.copy(other.centerZero),
      center = new Vector.copy(other.center),
      angleZero = other.angleZero,
      angle = other.angle;
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="angle">
<button class="show-code">Code</button>
num         <strong>angle</strong> <a class="anchor-link"
            href="#angle"
            title="Permalink to Sweep.angle">#</a>
        </h4>
        <div class="doc">
<pre class="source">
num angle;
</pre>
</div>
</div>
<div class="field"><h4 id="angleZero">
<button class="show-code">Code</button>
num         <strong>angleZero</strong> <a class="anchor-link"
            href="#angleZero"
            title="Permalink to Sweep.angleZero">#</a>
        </h4>
        <div class="doc">
<p>World angles.</p>
<pre class="source">
num angleZero;
</pre>
</div>
</div>
<div class="field"><h4 id="center">
<button class="show-code">Code</button>
final <a href="../box2d_html/Vector.html">Vector</a>         <strong>center</strong> <a class="anchor-link"
            href="#center"
            title="Permalink to Sweep.center">#</a>
        </h4>
        <div class="doc">
<pre class="source">
final Vector center;
</pre>
</div>
</div>
<div class="field"><h4 id="centerZero">
<button class="show-code">Code</button>
final <a href="../box2d_html/Vector.html">Vector</a>         <strong>centerZero</strong> <a class="anchor-link"
            href="#centerZero"
            title="Permalink to Sweep.centerZero">#</a>
        </h4>
        <div class="doc">
<p>Center world positions.</p>
<pre class="source">
final Vector centerZero;
</pre>
</div>
</div>
<div class="field"><h4 id="localCenter">
<button class="show-code">Code</button>
final <a href="../box2d_html/Vector.html">Vector</a>         <strong>localCenter</strong> <a class="anchor-link"
            href="#localCenter"
            title="Permalink to Sweep.localCenter">#</a>
        </h4>
        <div class="doc">
<p>Local center of mass position.</p>
<pre class="source">
final Vector localCenter;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="runtimeType">
<button class="show-code">Code</button>
final Type         <strong>runtimeType</strong> <a class="anchor-link"
            href="#runtimeType"
            title="Permalink to Sweep.runtimeType">#</a>
        </h4>
        <div class="inherited-from">inherited from Object </div><div class="doc">
<p>A representation of the runtime type of the object.</p>
<pre class="source">
external Type get runtimeType;
</pre>
</div>
</div>
</div>
<div>
<h3>Operators</h3>
<div class="method"><h4 id="==">
<button class="show-code">Code</button>
bool <strong>operator ==</strong>(other) <a class="anchor-link" href="#=="
              title="Permalink to Sweep.operator ==">#</a></h4>
<div class="doc">
<p>Returns true if given object is equal to this sweep. Two sweeps are equal
if their fields are equal.</p>
<pre class="source">
bool operator ==(other) {
  return localCenter == other.localCenter &amp;&amp; centerZero == other.centerZero
      &amp;&amp; center == other.center &amp;&amp; angleZero == other.angleZero &amp;&amp;
      angle == other.angle;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="advance">
<button class="show-code">Code</button>
void <strong>advance</strong>(num time) <a class="anchor-link" href="#advance"
              title="Permalink to Sweep.advance">#</a></h4>
<div class="doc">
<p>Advances the sweep forward, resulting in a new initial state.
Time is the new initial time.</p>
<pre class="source">
void advance(num time) {
  centerZero.x = (1 - time) * centerZero.x + time * center.x;
  centerZero.y = (1 - time) * centerZero.y + time * center.y;
  angleZero = (1 - time) * angleZero + time * angle;
}
</pre>
</div>
</div>
<div class="method"><h4 id="getTransform">
<button class="show-code">Code</button>
void <strong>getTransform</strong>(<a href="../box2d_html/Transform.html">Transform</a> xf, num alpha) <a class="anchor-link" href="#getTransform"
              title="Permalink to Sweep.getTransform">#</a></h4>
<div class="doc">
<p>Computes the interpolated transform at a specific time.
Time is the normalized time in <code>0,1</code>.</p>
<pre class="source">
void getTransform(Transform xf, num alpha) {
  assert (xf != null);

  xf.position.x = (1.0 - alpha) * centerZero.x + alpha * center.x;
  xf.position.y = (1.0 - alpha) * centerZero.y + alpha * center.y;
  xf.rotation.setAngle((1.0 - alpha) * angleZero + alpha * angle);

  // Shift to origin
  xf.position.x -= xf.rotation.col1.x * localCenter.x + xf.rotation.col2.x
      * localCenter.y;
  xf.position.y -= xf.rotation.col1.y * localCenter.x + xf.rotation.col2.y
      * localCenter.y;
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="hashCode">
<button class="show-code">Code</button>
int <strong>hashCode</strong>() <a class="anchor-link" href="#hashCode"
              title="Permalink to Sweep.hashCode">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Get a hash code for this object.</p>
<p>All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator <code>==</code>. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.</p>
<p>If a subclass overrides <code>hashCode</code> it should override the
equality operator as well to maintain consistency.</p>
<pre class="source">
external int hashCode();
</pre>
</div>
</div>
<div class="method"><h4 id="normalize">
<button class="show-code">Code</button>
void <strong>normalize</strong>() <a class="anchor-link" href="#normalize"
              title="Permalink to Sweep.normalize">#</a></h4>
<div class="doc">
<pre class="source">
void normalize() {
  num d = MathBox.TWO_PI * (angleZero / MathBox.TWO_PI).floor();
  angleZero -= d;
  angle -= d;
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="noSuchMethod">
<button class="show-code">Code</button>
<strong>noSuchMethod</strong>(String name, List args) <a class="anchor-link" href="#noSuchMethod"
              title="Permalink to Sweep.noSuchMethod">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p><code>noSuchMethod</code> is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to <code>noSuchMethod</code>. If <code>noSuchMethod</code>
returns a value, that value becomes the result of the original
invocation.</p>
<p>The default behavior of <code>noSuchMethod</code> is to throw a
<code>noSuchMethodError</code>.</p>
<pre class="source">
external Dynamic noSuchMethod(String name, List args);
</pre>
</div>
</div>
<div class="method inherited"><h4 id="Object">
<button class="show-code">Code</button>
const <strong>Object</strong>() <a class="anchor-link" href="#Object"
              title="Permalink to Sweep.Object">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Creates a new <code>Object</code> instance.</p>
<p><code>Object</code> instances have no meaningful state, and are only useful
through their identity. An <code>Object</code> instance is equal to itself
only.</p>
<pre class="source">
const Object();
</pre>
</div>
</div>
<div class="method"><h4 id="setFrom">
<button class="show-code">Code</button>
void <strong>setFrom</strong>(<a href="../box2d_html/Sweep.html">Sweep</a> other) <a class="anchor-link" href="#setFrom"
              title="Permalink to Sweep.setFrom">#</a></h4>
<div class="doc">
<p>Sets this Sweep equal to the given Sweep.</p>
<pre class="source">
void setFrom(Sweep other) {
  localCenter.setFrom(other.localCenter);
  centerZero.setFrom(other.centerZero);
  center.setFrom(other.center);
  angleZero = other.angleZero;
  angle = other.angle;
}
</pre>
</div>
</div>
<div class="method"><h4 id="Sweep">
<button class="show-code">Code</button>
new <strong>Sweep</strong>() <a class="anchor-link" href="#Sweep"
              title="Permalink to Sweep.Sweep">#</a></h4>
<div class="doc">
<p>Constructs a new Sweep with centers initialized to the origin and angles
set to zero.</p>
<pre class="source">
Sweep()
    : localCenter = new Vector(),
      centerZero = new Vector(),
      center = new Vector(),
      angleZero = 0,
      angle = 0;
</pre>
</div>
</div>
<div class="method"><h4 id="Sweep.copy">
<button class="show-code">Code</button>
new <strong>Sweep.copy</strong>(<a href="../box2d_html/Sweep.html">Sweep</a> other) <a class="anchor-link" href="#Sweep.copy"
              title="Permalink to Sweep.Sweep.copy">#</a></h4>
<div class="doc">
<p>Constructs a new sweep that is a copy of the given Sweep.</p>
<pre class="source">
Sweep.copy(Sweep other)
    : localCenter = new Vector.copy(other.localCenter),
      centerZero = new Vector.copy(other.centerZero),
      center = new Vector.copy(other.center),
      angleZero = other.angleZero,
      angle = other.angle;
</pre>
</div>
</div>
<div class="method inherited"><h4 id="toString">
<button class="show-code">Code</button>
String <strong>toString</strong>() <a class="anchor-link" href="#toString"
              title="Permalink to Sweep.toString">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Returns a string representation of this object.</p>
<pre class="source">
external String toString();
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
